/**
 * @file webpack env 编译常量
 */

const MODE_DEVELOPMENT = 'development'; // 开发环境
const MODE_RELEASE = 'release'; // 生产环境
const MODE_PRODUCTION = 'production'; // 生产环境

const VERSION = '3.7.8'; // 版本
const JSSDK_PATH_MAP = {
  // [MODE_DEVELOPMENT]: `http://localhost:9001/VhallSDK.js`,
  [MODE_DEVELOPMENT]:
    'https://t-alistatic01.e.vhall.com/jssdk-test01/dist/3.7.8/VhallSDK.js?t=' +
    new Date().getTime(),
  [MODE_RELEASE]:
    'https://cnstatic01.e.vhall.com/jssdk/dist/3.7.8/VhallSDK.js?t=' + new Date().getTime(),
  [MODE_PRODUCTION]:
    'https://cnstatic01.e.vhall.com/jssdk/dist/3.7.8/VhallSDK.js?t=' + new Date().getTime()
};

// 获取定义的变量值
const getEnv = () => {
  const raw = process.env;

  // 字段前缀
  const environmentPrefix = 'process.env';
  const stringified = {};

  Object.keys(raw).forEach(key => {
    stringified[`${environmentPrefix}.${key}`] = JSON.stringify(raw[key]);
  });
  return { raw, stringified };
};

module.exports = {
  MODE_DEVELOPMENT,
  MODE_RELEASE,
  MODE_PRODUCTION,
  getEnv,
  JSSDK_PATH_MAP,
  VERSION
};
